package Demarrage;

import java.awt.event.WindowAdapter;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import Composite.RacineDisqueDur;
import Composite.RacineVirtuelle;


public class ControleurQuitterApplication extends WindowAdapter{
    

    private JFrame fenetre;
    
    public ControleurQuitterApplication(JFrame fenetre) {
    
        this.fenetre=fenetre;

    }

    public void actionPerformed(ActionEvent e) {
        
        this.fermer();
    }
    
    public void windowClosing(WindowEvent e) {
        
        this.fermer();
        
    }

    
    public void fermer(){
        
        this.fenetre.setVisible(false);
        ObjectOutputStream fos=null;
         try {
                fos = new ObjectOutputStream(new FileOutputStream("sauvegarde/RacineVirtuelle.data"));
                fos.writeObject(RacineVirtuelle.getInstance());
 
                fos = new ObjectOutputStream(new FileOutputStream("sauvegarde/RacineDisqueDur.data"));
                fos.writeObject(RacineDisqueDur.getInstance());
 

            } catch (Exception ex) {
                ex.printStackTrace();
            }
          System.exit(0);  
        
    }
}
